package cz.muni.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;

/**
 *
 * @author Thomas
 */
@Entity
public class Shipment implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    @ManyToOne(optional=false)
    @JoinColumn(name="SENDER_ID",referencedColumnName="CUSTOMER_ID")
    private Customer sender;
    
    @ManyToOne(optional=false)
    @JoinColumn(name="TARRIF_ID",referencedColumnName="TARRIF_ID")
    private Tarrif tarrif;
    
    
    @ManyToOne(optional=false)
    @JoinColumn(name="RECIPIENT_ID",referencedColumnName="CUSTOMER_ID")
    private Customer recipient;
    
    @ManyToOne(optional=false)
    @JoinColumn(name="COURIER_ID",referencedColumnName="COURIER_ID")
    private Courier courier;

    private String shipmentState;
    
    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    private Date creationDate;
    
    private Double weight;
    
    private Double distance;
    
    private BigDecimal price;
    
    private Long trackingNumber;
    
    private String description;

    public Tarrif getTarrif() {
        return tarrif;
    }

    public void setTarrif(Tarrif tarrif) {
        this.tarrif = tarrif;
    }
    
    /**
     * Get the value of description
     *
     * @return the value of description
     */
    public String getDescription() {
        return description;
    }

    /**
     * Set the value of description
     *
     * @param description new value of description
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * Get the value of trackingNumber
     *
     * @return the value of trackingNumber
     */
    public Long getTrackingNumber() {
        return trackingNumber;
    }

    /**
     * Set the value of trackingNumber
     *
     * @param trackingNumber new value of trackingNumber
     */
    public void setTrackingNumber(Long trackingNumber) {
        this.trackingNumber = trackingNumber;
    }

    /**
     * Get the value of price
     *
     * @return the value of price
     */
    public BigDecimal getPrice() {
        return price;
    }

    /**
     * Set the value of price
     *
     * @param price new value of price
     */
    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    /**
     * Get the value of distance
     *
     * @return the value of distance
     */
    public Double getDistance() {
        return distance;
    }

    /**
     * Set the value of distance
     *
     * @param distance new value of distance
     */
    public void setDistance(Double distance) {
        this.distance = distance;
    }

    /**
     * Get the value of weight
     *
     * @return the value of weight
     */
    public Double getWeight() {
        return weight;
    }

    /**
     * Set the value of weight
     *
     * @param weight new value of weight
     */
    public void setWeight(Double weight) {
        this.weight = weight;
    }

    /**
     * Get the value of creationDate
     *
     * @return the value of creationDate
     */
    public Date getCreationDate() {
        return creationDate;
    }

    /**
     * Set the value of creationDate
     *
     * @param creationDate new value of creationDate
     */
    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    /**
     * Get the value of shipmentState
     *
     * @return the value of shipmentState
     */
    public String getShipmentState() {
        return shipmentState;
    }

    /**
     * Set the value of shipmentState
     *
     * @param shipmentState new value of shipmentState
     */
    public void setShipmentState(String shipmentState) {
        this.shipmentState = shipmentState;
    }


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Customer getSender() {
        return sender;
    }

    public void setSender(Customer sender) {
        this.sender = sender;
    }

    public Customer getRecipient() {
        return recipient;
    }

    public void setRecipient(Customer recipient) {
        this.recipient = recipient;
    }

    public Courier getCourier() {
        return courier;
    }

    public void setCourier(Courier courier) {
        this.courier = courier;
    }

    
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Shipment)) {
            return false;
        }
        Shipment other = (Shipment) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cz.muni.deliveryservice.entities.Shipment[ id=" + id + " ]";
    }
    
}
